import { t } from "@/i18n";
import { showToast } from "vant";
export const showLoading = () => {
  showLoadingToast({
    duration: 0,
    message: `${t("title11")}...`,
    forbidClick: true
  });
};

export const closeLoading = () => {
  closeToast();
};

export const showError = (error: Error | { message: string } | unknown) => {
  const errorMessage =
    typeof error === "object" && error !== null && "message" in error
      ? String(error.message)
      : String(error);

  showNotify({
    type: "danger",
    message: errorMessage,
    duration: 2000,
    position: "top"
  });
};

export const showMsg = (message: string) =>
  showToast({
    message,
    position: "top",
    duration: 2000
  });

export const showWarning = (message: string, duration = 1000) =>
  showNotify({
    type: "danger",
    duration,
    message: message
  });
